cc.Class({
    extends: cc.Component,

    properties: 
    {
        _ControlNode: null,  // 控制节点
        ControlNode:
        {
            get: function()
            {
                return this._ControlNode;
            },
            set: function(val)
            {
                this._ControlNode = val;
            },
            type: cc.Node,
        },

        _FromNode: null,      // 出发节点
        FromNode:
        {
            get: function()
            {
                return this._FromNode;
            },
            set: function(val)
            {
                this._FromNode = val;
            },
            type: cc.Node,
        },

        _ToNode: null,        // 到达节点
        ToNode:
        {
            get: function()
            {
                return this._ToNode;
            },
            set: function(val)
            {
                this._ToNode = val;
            },
            type: cc.Node,
        },

        _Speed: 100,    // 速度
        Speed:
        {
            get: function()
            {
                return this._Speed;
            },
            set: function(val)
            {
                this._Speed = val;
            }
        },

        _Type: 1,     // 1我方，2敌方
        Type:
        {
            get: function()
            {
                return this._Type;
            },
            set: function(val)
            {
                this._Type = val;
            }
        }
    },

    onLoad: function() 
    {
        this.ControlNode = cc.find("Canvas/ControlNode");
        this.controlScript = this.ControlNode.getComponent("MyControl");
    },

    start: function()
    {
        // this.node.setPosition(this.FromNode.node.position);
        // this.toPos = this.node.parent.convertToNodeSpaceAR(this.ToNode.node.position);
    },

    update: function(dt)
    {
        // let oldPos = this.node.position;
        // var direction = this.ToNode.node.position.sub(oldPos).normalize();
        // let direction = this.toPos.sub(oldPos).normalize();
        // let newPos = oldPos.add(direction.mul(this.Speed*dt));
        // this.node.setPosition(newPos); 
    },

    onCollisionEnter: function(other, self)
    {
        if(other.tag === 0)   
        {
            if(other.node === this.ToNode.node)
            {
                this.controlScript.onSoilderCollisionEnter(other, self)
            }
        }
        
    },
});
